package org.csmzxy.class2333;

import java.util.Scanner;

public class Work01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个整数：");
        int number = scanner.nextInt();
        if (isNarcissistic(number)) {
            System.out.println(number + "是一个水仙花数");
        } else {
            System.out.println(number + "不是一个水仙花数");
        }
        scanner.close();
    }
    public static boolean isNarcissistic(int number){
        int originalNumber = number;
        int sum = 0;
        int n =String.valueOf(number).length();
        while(number > 0){
            int digit = number % 10;
            sum += Math.pow(digit,n);
            number /=10;
        }
        return sum == originalNumber;
    }
}
